package com.example.leetcode.twopoint;

import com.example.leetcode.linkedlist.common.LinkedListUtils;
import com.example.leetcode.linkedlist.common.ListNode;
import com.example.leetcode.twopoint.common.TwoPointUtils;

/**
 * Definition for singly-linked list.
 * class ListNode {
 * int val;
 * ListNode next;
 * ListNode(int x) {
 * val = x;
 * next = null;
 * }
 * }
 */
class Solution141 {
    public boolean hasCycle(ListNode head) {
        return TwoPointUtils.hasCycle(head);
    }
}

public class leetcode141 {
    public static void main(String[] args) {
        Solution141 solution141 = new Solution141();
        int[] nums = {3, 2, 0, -4};
        int pos = 1;
        ListNode head = LinkedListUtils.generateLinkedListWithCycleByArray(nums, pos);
        System.out.println(solution141.hasCycle(head));
    }
}
